// house_pkg/pages/room/index.ts
Page({
  data: {
    point: '',
    building: '',
    rooms: [],
  },
  onLoad({ point, building }) {
    console.log(point, building)
    this.fack(point, building)
  },
  fack(point, building) {
    // 随机数                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        总共个数的房间号
    const size = Math.floor(Math.random() * 5) + 4
    // 用来装房间号的数组
    const rooms = []
    // 生成若干个房间号
    for (let i = 0; i < size; i++) {
      // 楼层号
      const floor = Math.floor(Math.random() * 19) + 1
      // 房间号
      const Nom = Math.floor(Math.random() * 2) + 1
      // 把楼层号和房间号拼凑
      const room = [floor, 0, Nom].join('')
      if (rooms.includes(room)) continue
      // 把生成的完整房间号推到数组中
      rooms.push(room)
    }
    this.setData({
      rooms,
      point,
      building,
    })
  },
})
